package com.cloud.user.impl.controller;

import com.cloud.user.impl.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import model.User;
import org.lwj.logger.api.LogMethod;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.security.PermitAll;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;


/**
 * @Author: :lwj
 * @Time: 2018-10-21 18:40
 * @Feature:
 */

@Api(tags ="用户")
@Controller
public class UserController {

    @Autowired
    private UserService userService;
    /**
     * @return
     */
    @ApiOperation(value = "user")
    @GetMapping("/user")
    @PermitAll
    public ResponseEntity<String> user(HttpServletRequest request){
        String key = request.getParameter("key");
        System.out.println(key);
        String remoteAddr = request.getRemoteAddr();
        System.out.println(remoteAddr);
        return ResponseEntity.ok("user");
    }
    public String getRemortIP(HttpServletRequest request) {
        if (request.getHeader("X-Forwarded-For") == null) {
            return request.getRemoteAddr();
        }
        String remoteAddr = request.getRemoteAddr();
        System.out.println(remoteAddr);
        return request.getHeader("X-Forwarded-For");
    }
}
